package com.punai.common.utils;

import cn.hutool.core.collection.CollUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class IMapUtil<K,V> {

    public static <K,V> Map<K,V> toMap(List<Map<String,Object>> listMap,String key,String valueKey) {
        Map<K,V> resMap = new HashMap<>();
        if (CollUtil.isNotEmpty(listMap)) {
            for (Map<String, Object> listItem : listMap) {
                K keyValue = (K)listItem.get(key);
                V valueValue = (V)listItem.get(valueKey);
                resMap.put(keyValue,valueValue);
            }
        }
        return resMap;
    }

}
